Skip to content

Integrate upstream CPU fixes (strided half-precision GEMM, cummax/cummin NaN) - #65

Merged
jjang-ai merged 2 commits into
osaurus-ai:mainfrom
rcfa:apple/r4-cpu
Nov 28, 2026
Merged

jjang-ai merged 2 commits into
osaurus-ai:mainfrom
rcfa:apple/r4-cpu

Conversation

@rcfa

@rcfa rcfa commented Nov 26, 2026

Copy link
Copy Markdown

Branch apple/r4-cpu, 2 commits on origin/main 23f364e (tip 6d29e52).

Two CPU fixes that reached ml-explore/mlx main on 2026-11-24, after round 3 was cut. The code is Apple's and its
contributors': each commit is a git cherry-pick -x of the upstream commit, with the upstream author kept and the
(cherry picked from commit …) line recording provenance.

Upstream Commit Here What it fixes
ml-explore#4947 c3ff43b bbdd174 The half-precision CPU matmuls ignored row strides, so segmented_mm in bf16/fp16 gave wrong values (ml-explore/mlx issue 4739). This fork's #26 already passed lda and ldb to simd_gemm. ml-explore#4947 also writes the output with its row stride ldc, in simd_gemm and in the BNNS output descriptor. Adds a C++ test.
ml-explore#4912 5598dfa 6d29e52 CPU cummax and cummin on float16 and bfloat16 turned NaN into 0: std::numeric_limits has no specialization for those types, so quiet_NaN() returned 0. NaN is now built from float and cast. Extends test_cummax_cummin_nan to float16 and bfloat16.

Conflict resolutions

Overlaps

None with the batch's other branches (merge-tree).

Validation

Compared with main (23f364e), built and run the same way:

Validation of the batch in shared

This batch's PRs but the last (fix/float-floor-divide, which came out of this validation), merged together on
main 23f364e with the two overlap resolutions (apple/fixes-2 and apple/r3-core in
python/tests/test_quantized.py; apple/r3-core and apple/fixes-3 in mlx/allocator.h), are mlx 8de1a51; vmlx-swift 31458a0d3 builds on it (osaurus-ai/vmlx-swift main bbd237750 with our open vmlx-swift
patches). Built and run, compared with main:

  • macOS (M4 Max, Release, Metal on): C++ suite 410 of 410 on the CPU and on Metal. vmlx-swift builds for macOS 14.0;
    its suite (swift test --no-parallel, 1046 tests) fails no test that passes on its main.
  • Linux arm64 and amd64 (containers, clang Release, Highway): C++ suite 431 of 431 on both (main 412 of 412).
    vmlx-swift's Linux CI steps pass: VMLXLinuxTests 37 of 37, the CPU kernel tests 61 of 61 at both thread settings.
  • Linux, the CI-equivalent Python run (osaurus-ai's Linux job, built and run the same way: GCC, Debug, Highway,
    DEVICE=cpu, python/tests module by module, torch 2.15 for the CPU). arm64: main 881 pass, 92 skip, 2 fail;
    the batch 906 pass, 96 skip, 2 fail (tree c43a37eec, which differs from 8de1a51 only in a C++ test). amd64: main
    882 pass, 92 skip, 1 fail; the batch 906 pass, 96 skip, 1 fail, 1 error. No test that passes on main fails on the batch. The failures are
    main's own: test_compile_sigmoid_matches_eager (bfloat16: the compiled CPU sigmoid is less accurate than the
    eager Highway kernel) and, on arm64 only, bfloat16 test_torch_conv_2D, where torch 2.15's own aarch64 bfloat16
    conv2d is off by up to 8.8 against float64 (MLX is within 0.06). test_async_eval_error_in_synchronize failed once on amd64; it fails about 1 run in 5 there on main too: the error it expects from synchronize can come from async_eval (the same code is on ml-explore/mlx main).
  • Three tests of main fail at random, on every branch alike, because they draw unseeded inputs or race:
    test_double.TestDouble.test_unary_ops in about 8% of runs (float32 erf is accurate to 1.5e-7 absolute, which
    misses rtol 1e-5 near 0 against the fork's accurate float64 erf); test_ops.TestOps.test_divmod in about 1%
    (the float16 quotient is off by one when a / b rounds up to an integer, e.g. 73.625 / 1.248 = 58.99 gives 59;
    ml-explore/mlx main has the same code); and, on amd64, test_async_eval_error_in_synchronize (above). This batch's
    fix/float-floor-divide fixes the second; the first gets a PR of its own.
  • osaurus-ai/mlx's GitHub Actions have not run since 2026-10-08, so this PR shows no checks; the runs above follow
    its Linux and macOS jobs.
  • This branch alone, the same Linux Python run (arm64): 881 pass, 92 skip, 2 fail: test_compile_sigmoid_matches_eager, test_torch_conv_2D as on main.

🤖 Generated with Claude Code

Yunt1 and others added 2 commits November 24, 2026 12:44
ml-explore#4947)

Co-authored-by: Yunt1 <Yunt1@users.noreply.github.com>
Co-authored-by: Cheng <git@zcbenz.com>

Ported: osaurus-ai/mlx PR 26 already passes lda and ldb to simd_gemm (the
fix for ml-explore/mlx issue 4739). This commit adds what PR 26 did not: ldc
for the output, and the BNNS dimensions. The Highway path
(simd_low_precision_gemm.h) passes ldc to its simd_gemm call too.
tests/blas_tests.cpp keeps PR 26's test and adds Apple's.

(cherry picked from commit c3ff43b)
@jjang-ai
jjang-ai merged commit 1a0193d into osaurus-ai:main Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants